home *** CD-ROM | disk | FTP | other *** search
- CSStateArray = new Object;
- CSCookieArray = new Object;
- CSCookieValArray = new Object;
-
- function CSWriteCookie(action) {
- var name = "DFT" + action[1];
- var hrs = action[2];
- var path = action[3];
- var domain = action[4];
- var secure = action[5];
-
- var exp = new Date((new Date()).getTime() + hrs * 3600000);
-
- var cookieVal = "";
- for(var prop in CSCookieArray) {
- if(("DFT" + CSCookieArray[prop]) == name) {
- if(cookieVal != "") cookieVal += "&";
- cookieVal += prop + ":" + escape(CSStateArray[prop]);
- }
- }
- if(hrs != 0)
- cookieVal += "; expires=" + exp.toGMTString();
- if(path != "")
- cookieVal += "; path=" + path;
- if(domain != "")
- cookieVal += "; domain=" + domain;
- if(secure == true)
- cookieVal += "; secure";
-
- //alert(cookieVal);
- document.cookie = name + '=' + cookieVal;
- }
-
- function CSReadCookie(action) {
- var name = "DFT" + action[1];
- var cookies = document.cookie;
-
- if(cookies == "") return;
-
- var start = cookies.indexOf(name);
- if(start == -1) return;
-
- start += name.length + 1;
- var end = cookies.indexOf(";", start);
- if(end == -1) end = cookies.length;
-
- var cookieVal = cookies.substring(start, end);
-
- var arr = cookieVal.split('&');
- for(var i = 0; i < arr.length; i++) {
- var a = arr[i].split(':');
- CSStateArray[a[0]] = unescape(a[1]);
- }
- }
-
- function CSDefineState(action) {
- CSCookieArray[action[1]] = action[3];
- }
-
- function CSSetState(action) {
- CSStateArray[action[1]] = action[2];
- }
-
- function CSInitState(action) {
- if(typeof(CSStateArray[action[1]]) == "undefined")
- CSStateArray[action[1]] = action[2];
- }
-
- function CSCheckState(action) {
- var obj1 = CSStateArray[action[1]];
- var obj2 = action[2];
-
- if(typeof(obj1) == "object") {
- for(var i=0;i<obj1.length;i++) {
- if(obj1[i] != obj2[i])
- return false;
- }
- return true;
- }
-
- var res;
- var op = action[3];
- if(op == "==") res = (CSStateArray[action[1]] == action[2]);
- else if(op == "!=") res = (CSStateArray[action[1]] != action[2]);
- else if(op == ">" ) res = (CSStateArray[action[1]] > action[2]);
- else if(op == ">=") res = (CSStateArray[action[1]] >= action[2]);
- else if(op == "<" ) res = (CSStateArray[action[1]] < action[2]);
- else if(op == "<=") res = (CSStateArray[action[1]] <= action[2]);
-
- return res;
- }
-
-